package pl.lodz.p.browarex.model;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.springframework.stereotype.Repository;

import pl.lodz.p.browarex.base.interfaces.IBaseModel;

@Entity
@Table(name = "ANALYSIS")
@Repository
public class AnalysisType implements IBaseModel<Long> {

	private Long id;
	private Customer customer;
	private String customerID;
	private Date date;
	private List<AnalysiesListType> analysies;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "ANALYSIS_ID")
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@OneToOne
	@JoinColumn(name = "CUSTOMER_ID", unique = false, nullable = false)
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}

	@Column(name = "CUSTOMER_STRING_ID", unique = false, nullable = false)
	public String getCustomerID() {
		return customerID;
	}

	public void setCustomerID(String customerID) {
		this.customerID = customerID;
	}

	@Column(name = "DATE", unique = false, nullable = false)
	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	@LazyCollection(LazyCollectionOption.FALSE)
	@OneToMany(cascade = CascadeType.ALL)
	public List<AnalysiesListType> getAnalysies() {
		return analysies;
	}

	public void setAnalysies(List<AnalysiesListType> analysies) {
		this.analysies = analysies;
	}

}
